package com.webapp.domain.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import com.alibaba.fastjson.annotation.JSONField;


/**
 * 对话关系/咨询师与纠纷表关系
 */
@Entity
public class Session extends BaseEntity{


	private static final long serialVersionUID = 1L;
	
	private Long id;
	
	private Disputes disputes;//纠纷
	private Counselor counselor;//咨询师
	private List<Message> messages;//对话记录
	private Date create_time;
	private String status;//状态
	
	private String opin; 		// 咨询师意见
	
	private String report;		// 结果报告
	
	private Date valid_time;//会话有效时间根据状态码自动计算插入,为null时记为无穷大
	private Date claim_time;//咨询师一键咨询认领时间
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	@OneToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="disputes_id",insertable=true,updatable=true)
	public Disputes getDisputes() {
		return disputes;
	}
	public void setDisputes(Disputes disputes) {
		this.disputes = disputes;
	}
	
	
	//	@OrderBy(value="desc")
	@OneToMany(mappedBy="session",cascade=CascadeType.ALL,fetch=FetchType.LAZY)
	@JSONField(serialize = false)
	public List<Message> getMessages() {
		return messages;
	}
	public void setMessages(List<Message> messages) {
		this.messages = messages;
	}
	
	
	
	@OneToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="counselor_id",insertable=true,updatable=true)
	@JSONField(serialize = false)
	public Counselor getCounselor() {
		return counselor;
	}
	public void setCounselor(Counselor counselor) {
		this.counselor = counselor;
	}
	public Date getCreate_time() {
		return create_time;
	}
	public void setCreate_time(Date create_time) {
		this.create_time = create_time;
	}
	
	@Column(name = "opin", length = 500)
	public String getOpin() {
		return opin;
	}
	public void setOpin(String opin) {
		this.opin = opin;
	}
	
	@Column(name = "status", length = 2)
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	@Column(name = "report", length = 2000)
	public String getReport() {
		return report;
	}
	public void setReport(String report) {
		this.report = report;
	}
	public Date getValid_time() {
		return valid_time;
	}
	public void setValid_time(Date valid_time) {
		this.valid_time = valid_time;
	}
	
	
	
	
	
	public Date getClaim_time() {
		return claim_time;
	}
	public void setClaim_time(Date claim_time) {
		this.claim_time = claim_time;
	}
	@Override
	public String toString() {
		return "Session [id=" + id + ", disputes=" + disputes + ", counselor=" + counselor + ", messages=" + messages
				+ ", create_time=" + create_time + ", status=" + status + ", opin=" + opin + ", report=" + report
				+ ", valid_time=" + valid_time + "]";
	}
	
	
	
}
